{% extends "base.html" %}

{% block content %}
<h1>Todo List for {{ user.username }}</h1>

<form hx-post="{% url 'todo:add_todo' %}" hx-target="#todo-list" hx-swap="beforeend">
    {% csrf_token %}
    <input type="text" name="task_text" placeholder="New task..." required>
    <button type="submit">Add</button>
</form>

<div id="todo-list">
    {% for todo in todos %}
        {% include "todo/partials/todo_item.html" with todo=todo %}
    {% endfor %}
</div>

{% if user.is_staff %}
    <hr>
    <h2><a href="{% url 'todo:admin_view' %}">Admin View</a></h2>
{% endif %}

{% endblock %}
